<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //先指定回调函数，后改变状态
        new Promise((resolve,reject)=>{
            setTimeout(() => {//此函数指定的异步延迟会先创建回调函数
                //后执行setTimeout函数，
                resolve(1)
            },1000);
        }).then(
            value =>{console.log(value);},
            reason =>{console.log('reason',reason);}
        )
         //先改变状态后指定回调函数
        new Promise((resolve,reject) =>{
            resolve(2)
        }).then(//后指定回调函数，异步执行回调函数
            value =>{console.log('value2',value),
            reason =>{console.log('reason2',reason)}
        }
        )
    </script>
</body>
</html>